#ifndef USART_H
#define USART_H

#include <stdint.h>
#include <stdio.h>
#include <avr/io.h>
#include <string.h>
#include <avr/interrupt.h>

#include "module_events.h"

//Function declarations
void usart_init(void);
void usart_run(void);
void usart_transmit(uint8_t data);
void usart_write( char *text);
void usart_writeln( char *text);
void usart_write_hexln(unsigned int c);
unsigned char usart_read(void);
char* usart_readln(void);
void usart_readln_start(void);
void usart_readln_ready(void);

//Defines
#define USART_BUFFER_SIZE 50

//global variables
uint8_t uc; //Last read character from USART
uint8_t uc_prev;
uint8_t usart_echo; //echo characters to terminal

//buffered line reader things
char usart_buffer[USART_BUFFER_SIZE+1];
uint8_t usart_buffer_index;
uint8_t volatile usart_readline;

#endif
